<template>
  <div class="block">
    <div class="txt">
      <h2>
        <a href="#">{{title}}</a>
      </h2>
      <p>{{brief}}</p>
    </div>
    <el-carousel class="elcenter" trigger="click" height="240px;">
      <el-carousel-item
        v-for="item in 3"
        :key="item"
        style="height: 247px; margin-top: 55px"
      >
        <div class="pic" style=" margin: 0 auto; padding-top: 26px;  position: relative" @click="tz">
          <img
            v-for="(src,i) of pic[item-1]" :key="i"
            :style="{ width, height }"
            @mouseenter="mouseEnter($event, '136px', '178px',i,item)"
            @mouseleave="mouseLeave($event, '126px', '168px' )"
            @click="getid(i,item)"
            :src="src.src"
            alt=""
            class="jump"
          />
        </div>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>
<script>
export default {
  data() {
    return {
      width: "126px",
      height: "168px",
      pic:[],
      title:'青春,等夏可以吗',
      brief:'在这部集合中，读者将会跟随作者的脚步，进入一处唯美，却夹杂着淡淡忧伤的意境，或许我们可以称之为一种叫做“青春”的特殊情感所设境地。作者用华丽的笔风……',
      bid:''
};
  },
  methods: {
     tz(){
        this.$router.push({path: `details/${this.bid}`})
        console.log(bid)
    },

    mouseEnter(e, w, h,i,item) {
      e.target.style.width=w
      e.target.style.height=h
      this.title = this.pic[item-1][i].title
      this.brief=this.pic[item-1][i].brief
    },
    mouseLeave(e, w, h) {
      e.target.style.width=w
      e.target.style.height=h
    },
    getid(i,item){
      this.bid=this.pic[item-1][i].bid
    }
  },
  mounted(){
    this.axios.get("/carousel/carousel").then(result=>{
       console.log(result.data.data);
       this.pic=result.data.data;
      this.pic =[
         [
            {src:result.data.data[0].md_img,title:result.data.data[0].title,brief:result.data.data[0].brief,bid:result.data.data[0].bid},
            {src:result.data.data[1].md_img,title:result.data.data[1].title,brief:result.data.data[1].brief,bid:result.data.data[1].bid},
            {src:result.data.data[2].md_img,title:result.data.data[2].title,brief:result.data.data[2].brief,bid:result.data.data[2].bid},
            {src:result.data.data[3].md_img,title:result.data.data[3].title,brief:result.data.data[3].brief,bid:result.data.data[3].bid}
        ],
         [
            {src:result.data.data[4].md_img,title:result.data.data[4].title,brief:result.data.data[4].brief,bid:result.data.data[4].bid},
            {src:result.data.data[5].md_img,title:result.data.data[5].title,brief:result.data.data[5].brief,bid:result.data.data[5].bid},
            {src:result.data.data[6].md_img,title:result.data.data[6].title,brief:result.data.data[6].brief,bid:result.data.data[6].bid},
            {src:result.data.data[7].md_img,title:result.data.data[7].title,brief:result.data.data[7].brief,bid:result.data.data[7].bid}
        ],
         [
            {src:result.data.data[8].md_img,title:result.data.data[8].title,brief:result.data.data[8].brief,bid:result.data.data[8].bid},
            {src:result.data.data[9].md_img,title:result.data.data[9].title,brief:result.data.data[9].brief,bid:result.data.data[9].bid},
            {src:result.data.data[10].md_img,title:result.data.data[10].title,brief:result.data.data[10].brief,bid:result.data.data[10].bid},
            {src:result.data.data[11].md_img,title:result.data.data[11].title,brief:result.data.data[11].brief,bid:result.data.data[11].bid}
        ],
      
      ]
    })
  }
};
</script>
<style scoped>
*{
    /* box-sizing: border-box; */
	margin: 0;
	padding: 0;
}
body{
	list-style: none;
  color:#9e9e9e;
	background: #f0f0f0;
  font:12px/20px "Microsoft Yahei", arial,sans-serif ;
  font-weight: normal;
}
.container{
	margin-left: auto;
	margin-right: auto;
	width: 1000px;
}
a {
    text-decoration: none;
    outline: none;
    font-family: "Microsoft Yahei", arial,sans-serif;
    color: #9e9e9e;
}
ul{
	margin: 0;
	padding: 0;
	list-style: none;
}
img {
	/* 让图片(行内块元素)与同一行中的内容竖直居中对齐 */
	vertical-align: middle;
}
input{
	outline: none;
}
h2,h3{
	font-style: normal;
	font-weight: normal;
}
s {
    background: url(https://pweb.d.zhangyue01.com/static/images/common/icon.png) no-repeat;
}
.elcenter{
  text-align: center;
}
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 150px;
  margin: 0;
}
.block .el-carousel {
  width: 1000px;
  height: 302px;
  margin: 0 auto;
}

.block {
  padding-top: 30px;
  background-image: url(https://pweb.d.ireader.com/static/images/index/bg.gif);
}
.block .txt {
  text-align: center;
  
}
.block .txt a {
  color: #fff;
  font-size: 24px;
  margin: 0 auto;
  padding: 6px 0;
  max-width: 704px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.block .txt p {
  height: 20px;
  font-size: 16px;
  color: #fff;
  margin: 0 auto;
  max-width: 516px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity:0.3;
}
img {
  width: 126px;
  height: 168px;
  margin: 0 18px;
  transition: 1s;
}
.el-carousel__button{
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
</style>
